﻿@{
    Layout = "~/Views/Shared/_Index.cshtml";
}
<div class="container-div">
    <div class="row">
        <div id="searchDiv" class="col-sm-12 search-collapse">
            <div class="select-list">
                <ul>
                    <li>
                        城市名称：<input id="companyName" col="CompanyName" type="text" />
                    </li>
                    <li>
                        <a id="btnSearch" class="btn btn-primary btn-sm" onclick="searchGrid()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                    </li>
                </ul>
            </div>
        </div>
        <div class="col-sm-12  select-table table-striped talbe-sm table-bordered  text-nowrap">
            <table class="table-responsive" id="gridTable" data-mobile-responsive="true"></table>
        </div>

        @*按钮样式-----------------------------------*@
        <!--<button type="button" class="btn btn-primary">Primary</button>
        <button type="button" class="btn btn-secondary">Secondary</button>
        <button type="button" class="btn btn-success">Success</button>
        <button type="button" class="btn btn-danger">Danger</button>
        <button type="button" class="btn btn-warning">Warning</button>
        <button type="button" class="btn btn-info">Info</button>
        <button type="button" class="btn btn-light">Light</button>
        <button type="button" class="btn btn-dark">Dark</button>

        <button type="button" class="btn btn-link">Link</button>

        <div class="btn-group" role="group" aria-label="Basic example">
            <button type="button" class="btn btn-success">Left</button>
            <button type="button" class="btn btn-success">Middle</button>
            <button type="button" class="btn btn-success">Right</button>
        </div>-->
        @*折叠效果-----------------------*@
        <!--<div class="accordion" id="accordionExample">
            <div class="card">
                <div class="card-header" id="headingOne">
                    <h2 class="mb-0">
                        <button class="btn btn-link btn-block text-left" type="button" data-toggle="collapse" data-target="#collapseOne" aria-expanded="true" aria-controls="collapseOne">
                            Collapsible Group Item #1
                        </button>
                    </h2>
                </div>

                <div id="collapseOne" class="collapse show" aria-labelledby="headingOne" data-parent="#accordionExample">
                    <div class="card-body">
                        Some placeholder content for the first accordion panel. This panel is shown by default, thanks to the <code>.show</code> class.
                    </div>
                </div>
            </div>
            <div class="card">
                <div class="card-header" id="headingTwo">
                    <h2 class="mb-0">
                        <button class="btn btn-link btn-block text-left collapsed" type="button" data-toggle="collapse" data-target="#collapseTwo" aria-expanded="false" aria-controls="collapseTwo">
                            Collapsible Group Item #2
                        </button>
                    </h2>
                </div>
                <div id="collapseTwo" class="collapse" aria-labelledby="headingTwo" data-parent="#accordionExample">
                    <div class="card-body">
                        Some placeholder content for the second accordion panel. This panel is hidden by default.
                    </div>
                </div>
            </div>
            <div class="card">
                <div class="card-header" id="headingThree">
                    <h2 class="mb-0">
                        <button class="btn btn-link btn-block text-left collapsed" type="button" data-toggle="collapse" data-target="#collapseThree" aria-expanded="false" aria-controls="collapseThree">
                            Collapsible Group Item #3
                        </button>
                    </h2>
                </div>
                <div id="collapseThree" class="collapse" aria-labelledby="headingThree" data-parent="#accordionExample">
                    <div class="card-body">
                        And lastly, the placeholder content for the third and final accordion panel. This panel is hidden by default.
                    </div>
                </div>
            </div>
        </div>


        <div class="dropdown">
            <button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                Dropdown button
            </button>
            <div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
                <a class="dropdown-item" href="#">Action</a>
                <a class="dropdown-item" href="#">Another action</a>
                <a class="dropdown-item" href="#">Something else here</a>
            </div>
        </div>-->


    </div>
</div>

<script type="text/javascript">
    $(function () {
        initGrid();
    });

    function initGrid() {
        console.log("HelloWorld");
        @*var queryUrl = '@Url.Content("~/OrganizationManage/Company/GetPageListJson")';
        $('#gridTable').ysTable({

            url: queryUrl,
            columns: [
                { checkbox: true, visible: true },
                { field: 'Id', title: 'Id', visible: false },
                { field: 'CompanyID', title: '公司代码' },
                { field: 'CompanyName', title: '公司名称'},
                { field: 'Address', title: '地址' },
                { field: 'ShortName', title: '简称' },
                {
                    field: 'HeadFlag',
                    title: '总部标识',
                    formatter: function (value, row, index) {
                        if (value == true) {
                            return '是';
                        }
                        else {
                            return '否';
                        }
                    }
                },
                {
                    field: 'UseSAP', title: '来自SAP',
                    formatter: function (value, row, index) {
                        if (value == true) {
                            return '是';
                        }
                        else {
                            return '否';
                        }
                    }},
                { field: 'CompanyEnglistName', title: '英文名称' },
                { field: 'CorperRepresentation', title: '法人代表' },
                { field: 'CountryID', title: '国家' },
                { field: 'CityID', title: '城市' },
                { field: 'BasicMoneyType', title: '基础货币' },
                { field: 'AccountantCourseList', title: '会计科目表' },
                { field: 'FiscalYearVarID', title: '会计年度变式' },
                { field: 'CompanyAdderess1', title: '公司地址1' },
                { field: 'CompanyAdderess2', title: '公司地址2' },
                { field: 'CompanyAdderess3', title: '公司地3' },
                { field: 'ChargeUpPeriodVar', title: '记账期间变式' },
                { field: 'FieldStateVar', title: '字段状态变式' },
                { field: 'IntroductionText', title: '简介' },
                { field: 'industryClass', title: '行业领域' },
                { field: 'Memo', title: '备注' },
            ],
            search:true,
            queryParams: function (params) {
                var pagination = $('#gridTable').ysTable('getPagination', params);
                var queryString = $('#searchDiv').getWebControls(pagination);
                return queryString;
            }
        });*@
    }

    function searchGrid() {
        $('#gridTable').ysTable('search');
        resetToolbarStatus();
    }

    function showSaveForm(bAdd) {
        @*var id = 0;
        if (!bAdd) {
            var selectedRow = $('#gridTable').bootstrapTable('getSelections');
            if (!ys.checkRowEdit(selectedRow)) {
                return;
            }
            else {
                id = selectedRow[0].Id;
            }
        }
        ys.openDialog({
            title: id > 0 ? '编辑' : '添加',
            content: '@Url.Content("~/OrganizationManage/Company/CompanyForm")' + '?id=' + id,
            width: '768px',
            height: '550px',
            callback: function (index, layero) {
                var iframeWin = window[layero.find('iframe')[0]['name']];
                iframeWin.saveForm(index);
            }
        });*@
    }

    function deleteForm() {
        var selectedRow = $('#gridTable').bootstrapTable('getSelections');
        if (ys.checkRowDelete(selectedRow)) {
            ys.confirm('确认要删除选中的' + selectedRow.length + '条数据吗？', function () {
                var ids = ys.getIds(selectedRow);
                ys.ajax({
                    url: '@Url.Content("~/OrganizationManage/Company/DeleteFormJson")' + '?ids=' + ids,
                    type: 'post',
                    success: function (obj) {
                        if (obj.Tag == 1) {
                            ys.msgSuccess(obj.Message);
                            searchGrid();
                        }
                        else {
                            ys.msgError(obj.Message);
                        }
                    }
                });
            });
        }
    }
</script>
